package com.example.ViewPagerSum.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ViewPagerSum.R;
import com.example.ViewPagerSum.adapter.TabPageIndicatorAdapter;
import com.viewpagerindicator.TabPageIndicator;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangjing on 2015/9/8at23:53.
 * <p/>
 * Email:wjontheway@163.com
 * <p/>
 * ViewPagerSum
 */
public class HomeFragment extends Fragment {

    private ViewPager viewPager = null;
    //Fragment适配器
    private FragmentPagerAdapter mFragmentPagerAdapter;
    //指示器
    protected TabPageIndicator mTabPageIndicator;
    //Fragment的集合，总共三个
    private List<Fragment> fragmentList = new ArrayList<>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = null;
        view = inflater.inflate(R.layout.fragment_home, container, false);
        fragmentList.add(new SubPortraitMmFragment());//写真
        fragmentList.add(new SubPureMmFragment());//清纯

        fragmentList.add(new SubPhotoMmFragment());//照片
        fragmentList.add(new SubRHMmFragment());//日韩
        fragmentList.add(new SubSexMmFragment());//性感
        fragmentList.add(new SubLegMmFragment());//美腿
        fragmentList.add(new SubCarMmFragment());//车模

        viewPager = (ViewPager) view.findViewById(R.id.viewpager);
        viewPager.setOffscreenPageLimit(4);
        mTabPageIndicator = (TabPageIndicator) view.findViewById(R.id.titles);
        mFragmentPagerAdapter = new TabPageIndicatorAdapter(getChildFragmentManager(), fragmentList);
        viewPager.setAdapter(mFragmentPagerAdapter);
        mTabPageIndicator.setViewPager(viewPager);
        return view;
    }
}
